package com.fjh.roadmannage.ui

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.OnLifecycleEvent
import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.ext.sss
import com.cxz.kotlin.baselibs.mvp.IView
import com.fjh.roadmannage.base.Presenter
import com.fjh.roadmannage.bean.User
import com.fjh.roadmannage.http.MainRetrofit

interface MainContract {
    interface MainView : IView {
        fun getLoginParam(): Pair<String, String>
        fun loginSuc(user: User)
    }

    class MainPresenter : Presenter<MainView>() {

        fun login() {
            MainRetrofit.service.login(
                mView?.getLoginParam()!!.first,
                mView?.getLoginParam()!!.second
            ).sss(mView, true, {
                if (it != null) {
                    mView?.loginSuc(it)
                }
            }).let { addDisposable(it) }
//
//            use({
//                MainRetrofit.service.login(
//                    mView?.getLoginParam()!!.first,
//                    mView?.getLoginParam()!!.second
//                )
//            }, {
//                if (it != null) {
//                    mView?.loginSuc(it)
//                }
//            })
        }
    }
}